import Vue from 'vue';
import Comp from './comp';

const compConstructor = Vue.extend(Comp);
let instance = null;

const showComp = (options = {}) => {
  if (instance) instance = null;
  let conatiner = document.createElement('div');
  document.body.appendChild(conatiner);

  instance = new compConstructor({
    propsData: {
      visible: options.visible
      // ...options
    }
  });

  instance.$mount(conatiner);

  instance.$on('click', () => {
    if (options.onClick) options.onClick();
  });

  return instance;
}

Vue.prototype.$showComp = showComp;
